#ifndef VideoOutputWidgetH
#define VideoOutputWidgetH
#include "myCBIR_FrameReceiver.h"
#include "myCBIR_FrameCapture.h"
#include "myCBIR_Controller.h"
#include "myCBIR_Detector.h"
#include "myCBIR_FaceDetector.h"
#include <boost/thread/mutex.hpp>
#include <string>

namespace myCBIR
{
    class FrameReceiver;
    class Controller;

    class VideoOutputWidget: public FrameReceiver, public Controller
    {
        public:
            VideoOutputWidget(FrameCapture* existingCaptureDevice, FaceDetector *faceDetector);
            VideoOutputWidget(const std::string &winName, FrameCapture* existingCaptureDevice, FaceDetector *faceDetector);
            ~VideoOutputWidget();

            void update();
            void receiveFrame(const cv::Mat &frame);
            void stateChanged(Detector *detector);

        private:
             void loadNextFrameIntoCurrent();

            //lock for loading new frames
            Detector::RectVector faces;
            boost::mutex frameLoadLock;
            char key;
            std::string sWinName;
            cv::Mat currentFrame;
            cv::Mat nextFrame;

            FrameCapture* pCaptureDevice;
            FaceDetector* pFaceDetector;
    };
}

#endif